package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MedicineDetailMapper;
import com.ruoyi.system.domain.MedicineDetail;
import com.ruoyi.system.service.IMedicineDetailService;

/**
 * 药品说明详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-17
 */
@Service
public class MedicineDetailServiceImpl implements IMedicineDetailService 
{
    @Autowired
    private MedicineDetailMapper medicineDetailMapper;

    /**
     * 查询药品说明详情
     * 
     * @param id 药品说明详情主键
     * @return 药品说明详情
     */
    @Override
    public MedicineDetail selectMedicineDetailById(Long id)
    {
        return medicineDetailMapper.selectMedicineDetailById(id);
    }

    /**
     * 查询药品说明详情列表
     * 
     * @param medicineDetail 药品说明详情
     * @return 药品说明详情
     */
    @Override
    public List<MedicineDetail> selectMedicineDetailList(MedicineDetail medicineDetail)
    {
        return medicineDetailMapper.selectMedicineDetailList(medicineDetail);
    }

    /**
     * 新增药品说明详情
     * 
     * @param medicineDetail 药品说明详情
     * @return 结果
     */
    @Override
    public int insertMedicineDetail(MedicineDetail medicineDetail)
    {
        medicineDetail.setContent(medicineDetail.getContent().replaceAll("   ","&nbsp;"));
        medicineDetail.setCreateTime(DateUtils.getNowDate());
        return medicineDetailMapper.insertMedicineDetail(medicineDetail);
    }

    /**
     * 修改药品说明详情
     * 
     * @param medicineDetail 药品说明详情
     * @return 结果
     */
    @Override
    public int updateMedicineDetail(MedicineDetail medicineDetail)
    {
        medicineDetail.setUpdateTime(DateUtils.getNowDate());
        return medicineDetailMapper.updateMedicineDetail(medicineDetail);
    }

    /**
     * 批量删除药品说明详情
     * 
     * @param ids 需要删除的药品说明详情主键
     * @return 结果
     */
    @Override
    public int deleteMedicineDetailByIds(Long[] ids)
    {
        return medicineDetailMapper.deleteMedicineDetailByIds(ids);
    }

    /**
     * 删除药品说明详情信息
     * 
     * @param id 药品说明详情主键
     * @return 结果
     */
    @Override
    public int deleteMedicineDetailById(Long id)
    {
        return medicineDetailMapper.deleteMedicineDetailById(id);
    }

    @Override
    public int deleteMedicineDetailByMidicineId(MedicineDetail medicineDetail) {
        return medicineDetailMapper.deleteMedicineDetailByMedicineId(medicineDetail);
    }
}
